﻿

//声明了个控制权名称：common.views.disputeInformations.index
(function () {
    appModule.controller('common.views.disputeInformationHandles.compareStatistics', [
      '$scope', '$uibModal', '$stateParams', 'uiGridConstants', 'abp.services.app.disputeInformation', 'abp.services.app.area', "$state", 'abp.services.app.disputeType',
        function ($scope, $uibModal, $stateParams, uiGridConstants, disputeInformationService, areaService, $state, disputeTypeService) {
            var vm = this;

            $scope.$on('$viewContentLoaded', function () {
                //这里应该是当页面加载完毕后，进行信息的初始化
                //实际会去调用 icheck、select2等js的初始化插件。来渲染页面
                App.initAjax();
            });
            //告知页面信息已经下载完毕
            vm.loading = false;

            //初始化时间控件
            vm.dateRangeOptions = app.createDateRangePickerOptions();
            vm.dateRangeModelOne = {
                startDate: '',
                endDate: ''
            };
            vm.dateRangeModelTwo = {
                startDateTwo: '',
                endDateTwo: ''
            };

            //请求参数，默认用于分页
            vm.requestParams = {
                permission: '',
                role: '',
                skipCount: 0,
                //这里是个常量文件，如果你没有找到这个常量文件，那么就手动改成10吧
                maxResultCount: app.consts.grid.defaultPageSize,
                sorting: null,
                party: "",
                townID: 0,
                areaID: 0,
                villageID: 0,
                Status: 0,
                endStaus: 0,
                startDate: '',
                endDate: '',
                disputeTypeID: 0
            };

            //返回
            vm.back = function () {
                //跳转页面
                $state.go('fenXiYanPan');
            };

            vm.loadControl = function () {
                vm.loading = true;
                disputeInformationService.getTownPie($.extend({ filter: vm.filterText }, vm.requestParams))
                    .then(function (result) {

                        var data = result.data.items;
                        var jsonStr = "";
                        jsonStr += "[";
                        for (var i = 0; i < data.length; i++) {
                            jsonStr += "['" + data[i].x + "', " + data[i].y + "],";
                        }
                        jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
                        jsonStr += "]";

                        var json = eval(jsonStr);

                        $('#graph').highcharts({
                            chart: {
                                type: 'column'
                            },
                            title: {
                                text: '纠纷在乡镇中的占比'
                            },
                            xAxis: {
                                type: 'category',
                                labels: {
                                    //rotation: 0,
                                    style: {
                                        fontSize: '13px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            },
                            yAxis: {
                                min: 0,
                                allowDecimals: false,
                                title: {
                                    text: '纠纷占比'
                                },
                                labels: {
                                    formatter: function () {
                                        return this.value + '%';
                                    }
                                }
                            },
                            legend: {
                                enabled: false
                            },
                            tooltip: {
                                pointFormat: '纠纷占比: <b>{point.y} %</b>'
                            },
                            series: [{
                                name: '总人口',
                                data: json,
                                dataLabels: {
                                    enabled: true,
                                    //rotation: -90,
                                    color: '#FFFFFF',
                                    align: 'center',
                                    format: '{point.y}%', // one decimal
                                    //y: 0, // 10 pixels down from the top
                                    style: {
                                        fontSize: '13px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            }]
                        });

                        $('#graph1').highcharts({
                            chart: {
                                type: 'column'
                            },
                            title: {
                                text: '纠纷在乡镇中的占比'
                            },
                            xAxis: {
                                type: 'category',
                                labels: {
                                    //rotation: 0,
                                    style: {
                                        fontSize: '13px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            },
                            yAxis: {
                                min: 0,
                                allowDecimals: false,
                                title: {
                                    text: '纠纷占比'
                                },
                                labels: {
                                    formatter: function () {
                                        return this.value + '%';
                                    }
                                }
                            },
                            legend: {
                                enabled: false
                            },
                            tooltip: {
                                pointFormat: '纠纷占比: <b>{point.y} %</b>'
                            },
                            series: [{
                                name: '总人口',
                                data: json,
                                dataLabels: {
                                    enabled: true,
                                    //rotation: -90,
                                    color: '#FFFFFF',
                                    align: 'center',
                                    format: '{point.y}%', // one decimal
                                    //y: 0, // 10 pixels down from the top
                                    style: {
                                        fontSize: '13px',
                                        fontFamily: 'Verdana, sans-serif'
                                    }
                                }
                            }]
                        });

                    }).finally(function () {
                        vm.loading = false;
                    });
            };

            vm.loadControl();

        }
    ]);
})();









